package org.apache.ibatis.session;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.HashMap;
import java.util.Map;

public class SqlSessionFactory {
	
	private Connection conn;
	
	private String driver;
	private String url;
	private String username;
	private String password;
	private Map<String,SelectStatement> selectStatementMap = new HashMap<String,SelectStatement>();
	
	public Map<String, SelectStatement> getSelectStatementMap() {
		return selectStatementMap;
	}
	public void setSelectStatementMap(Map<String, SelectStatement> selectStatementMap) {
		this.selectStatementMap = selectStatementMap;
	}
	public String getDriver() {
		return driver;
	}
	public void setDriver(String driver) {
		this.driver = driver;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public SqlSession openSession(){
		SqlSession sqlSession = new SqlSession();
		
		try {
			Class.forName(driver);
			Connection conn = DriverManager.getConnection(url, username, password);
			sqlSession.setConn(conn);
			sqlSession.setSelectStatementMap(selectStatementMap);
		} catch (Exception e) {

			e.printStackTrace();
		}
		
		return sqlSession;
	}
}
